Conversation
Co-authored-by: ArchILLtect <140122527+ArchILLtect@users.noreply.github.com>
Co-authored-by: ArchILLtect <140122527+ArchILLtect@users.noreply.github.com>
Co-authored-by: ArchILLtect <140122527+ArchILLtect@users.noreply.github.com>
Co-authored-by: ArchILLtect <140122527+ArchILLtect@users.noreply.github.com>
…tication vulnerability Co-authored-by: ArchILLtect <140122527+ArchILLtect@users.noreply.github.com>
…to-neon ci/tooling: migrate database from AWS RDS MySQL to Neon Postgres
There was a problem hiding this comment.
Pull request overview
This pull request migrates the project's database infrastructure from MySQL to PostgreSQL, using Neon as the serverless production database provider. The migration updates all database connection configurations, SQL schemas, dependency declarations, and documentation to support PostgreSQL throughout the development, testing, and deployment lifecycle.
Changes:
- Replaced MySQL JDBC driver with PostgreSQL driver (version 42.7.7) and updated all Hibernate configurations to use PostgreSQL dialect and connection URLs
- Converted SQL schema scripts from MySQL syntax to PostgreSQL syntax, replacing
AUTO_INCREMENTwithGENERATED ALWAYS AS IDENTITY,ENUMwithVARCHAR+CHECKconstraints, and MySQL-specific timestamp updates with standard defaults - Updated deployment documentation to describe Neon PostgreSQL setup, environment variables, and SSL requirements; revised README to reflect PostgreSQL as the database for all environments
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/test/resources/test-db.properties.example |
Added PostgreSQL connection template for local testing with proper driver, dialect, and SSL configuration |
src/test/resources/cleandb.sql |
Converted test schema from MySQL to PostgreSQL syntax (identity columns, constraints, enum handling) |
src/test/java/me/nickhanson/codeforge/testutil/Database.java |
Updated error message to be database-agnostic |
src/main/resources/hibernate.cfg.xml |
Changed JDBC driver, dialect, and connection URL from MySQL to PostgreSQL with SSL enabled |
src/main/resources/data.sql |
Added missing user_id column to INSERT statements for submissions and drill items |
src/main/java/me/nickhanson/codeforge/persistence/SessionFactoryProvider.java |
Updated default port, JDBC URL format, and driver class to PostgreSQL; changed dialect default |
pom.xml |
Replaced MySQL connector dependency with PostgreSQL JDBC driver |
docs/deployment.md |
Revised deployment guide to describe Neon PostgreSQL setup, removed RDS-specific instructions, added migration guidance |
README.md |
Updated database technology description from MySQL to PostgreSQL/Neon |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -90,48 +84,41 @@ For production (AWS RDS), override datasource and JPA properties with environmen | |||
|
|
|||
There was a problem hiding this comment.
This section references "Spring" properties and "application.yml", but this project uses Hibernate directly without Spring (as documented at the top of the file). Remove or update this section to reflect Hibernate-specific configuration instead of Spring configuration.
|
|
||
| CREATE TABLE submissions ( | ||
| id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
| id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, |
There was a problem hiding this comment.
Using GENERATED ALWAYS AS IDENTITY prevents explicit ID insertion, which is correct for these tables. However, if you ever need to insert rows with specific IDs (e.g., for testing or data migration), consider using GENERATED BY DEFAULT AS IDENTITY instead. The current approach is more secure but less flexible.
| id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, | |
| id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, |
| - PostgreSQL (Neon for production, local for dev/tests) | ||
| - Test DB reset via `DbReset` + `cleandb.sql` | ||
| - Seed data managed in `src/test/resources/cleandb.sql` (predictable schema) | ||
| - **AWS RDS** — Cloud-hosted DB for deployment | ||
| - **Neon (Postgres)** — Cloud-hosted serverless DB for deployment |
There was a problem hiding this comment.
The README still contains multiple references to MySQL that need to be updated to PostgreSQL, including:
- "Tests use a local MySQL test database" (line 272)
- "Create a local MySQL test database" section heading (line 274)
- "Ensure MySQL is running locally" (line 279)
- Example connection properties showing MySQL driver and dialect (lines 293-297)
These sections should be updated to reflect the PostgreSQL migration.
| url = "jdbc:postgresql://" + host + ":" + port + "/" + db | ||
| + "?ssl=true&sslmode=require"; |
There was a problem hiding this comment.
The default JDBC URL uses ssl=true&sslmode=require, which will fail when connecting to a local PostgreSQL instance for development. Local PostgreSQL typically doesn't have SSL configured. Consider detecting localhost connections and disabling SSL for them (e.g., ssl=false when host is "localhost"), while keeping SSL enabled for production. The test-db.properties.example correctly uses ssl=false for local development.
| url = "jdbc:postgresql://" + host + ":" + port + "/" + db | |
| + "?ssl=true&sslmode=require"; | |
| boolean isLocalhost = "localhost".equalsIgnoreCase(host) || "127.0.0.1".equals(host); | |
| String sslParams = isLocalhost ? "?ssl=false" : "?ssl=true&sslmode=require"; | |
| url = "jdbc:postgresql://" + host + ":" + port + "/" + db + sslParams; |
| jdbc:postgresql://${DB_HOST}:5432/${DB_NAME} | ||
| ?ssl=true | ||
| &sslmode=require |
There was a problem hiding this comment.
The default JDBC URL includes ssl=true&sslmode=require, but this will fail for local development connections to PostgreSQL. The test-db.properties.example correctly uses ssl=false for local development. Consider making SSL conditional based on the environment (e.g., ssl=false for localhost, ssl=true&sslmode=require for production).
| jdbc:postgresql://${DB_HOST}:5432/${DB_NAME} | |
| ?ssl=true | |
| &sslmode=require | |
| jdbc:postgresql://${DB_HOST}:5432/${DB_NAME}${DB_SSL_OPTIONS} |
| @@ -18,23 +18,18 @@ This project runs as a WAR on Tomcat 9 (Jakarta Servlet API). The persistence la | |||
| ### Dev/Test (default) | |||
| - `src/main/resources/hibernate.cfg.xml` points to H2 and sets `hbm2ddl.auto=update`. | |||
There was a problem hiding this comment.
This documentation still mentions "H2 in-memory DB" for Dev/Test, but the changes migrate to PostgreSQL for all environments. Update this to reflect the new PostgreSQL-based setup for local development and testing.
| - `src/main/resources/hibernate.cfg.xml` points to H2 and sets `hbm2ddl.auto=update`. | |
| - `src/main/resources/hibernate.cfg.xml` is configured for a local PostgreSQL instance (or Docker) and sets `hbm2ddl.auto=update`. |
This pull request migrates the project’s database from MySQL to PostgreSQL, with Neon as the production database provider. The changes update the codebase, configuration files, and documentation to support PostgreSQL throughout development, testing, and deployment. Schema scripts and seed data are also adapted for PostgreSQL syntax and conventions.
Database migration to PostgreSQL:
SessionFactoryProvider.java,hibernate.cfg.xml, and test configuration files to use PostgreSQL instead of MySQL. [1] [2] [3] [4]pom.xml. [1] [2]cleandb.sqlanddata.sqlto PostgreSQL syntax, including identity columns, enum handling, and unique constraints. [1] [2] [3]Documentation and deployment updates:
README.mdanddocs/deployment.mdto describe PostgreSQL usage for dev/test/prod, with Neon as the serverless production database. Includes new instructions for configuring environment variables and JDBC URLs. [1] [2] [3] [4] [5]Testing and troubleshooting improvements: